/*
 * $Id: PictureBox.java 158 2009-05-22 12:22:12Z meyer@alphatec.de $
 * 
 *
 * Copyright 2009 DeltaDesk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package deltadesk.gui.deltagui.widget.box;

import java.awt.Graphics2D;
import java.net.URL;

import deltadesk.gui.deltagui.widget.AutoFitPanel;
import deltadesk.gui.deltagui.widget.Picture;

/**
 * PictureBox.
 * 
 * @author Andreas Meyer
 * @version $Revision: 158 $
 */
public class PictureBox extends Box {

	/** The picture viewer widget. */
	private AutoFitPanel pictureViewer;
	
	/** The text widget. */
	private String text;


	/**
	 * Construct the box.
	 * 
	 * @param url
	 */
	public PictureBox(final URL url) {
		this(url.getFile(), url);
	}

	/**
	 * Construct the box.
	 * 
	 * @param text
	 * @param url
	 */
	public PictureBox(final String text, final URL url) {

		this.text = text;

		pictureViewer = new AutoFitPanel(new Picture(url));
		super.add(pictureViewer);
	}

	/**
	 * @param scaleUp the scaleUp to set
	 */
	public void setScaleUp(final boolean scaleUp) {
		pictureViewer.setScaleUp(scaleUp);
	}

	/**
	 * @see deltadesk.deepspace.widget.box.Box#renderControl(java.awt.Graphics2D)
	 */
	@Override
	public void renderControl(final Graphics2D g2) {
		super.renderControl(g2);
		
		g2.drawString(text, 10, 25);
	}

}
